package com.quanyan.activity.web;

import com.quanyan.activity.entity.vo.req.ReqActivityMediaInfo;
import com.quanyan.activity.entity.vo.res.RespActivityMedia;
import com.quanyan.activity.service.ActivityMediaService;
import com.quanyan.activity.service.ActivityOpenService;
import com.quanyan.activity.service.ActivityService;
import com.quanyan.api.APIResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * ProductController
 *
 * @author Li Shuai
 * @date 16/5/26
 */
@RestController
@RequestMapping("/api/activity")
public class ActivityController extends BaseController{
    @Autowired
    private ActivityService activityService;
    @Autowired
    private ActivityOpenService activityOpenService;
    @Autowired
    private ActivityMediaService mediaService;

    /**
     * 新增活动多媒体
     */
    @RequestMapping(value = "/addActivityMedia", method = RequestMethod.POST)
    public APIResponse addActivityMedia(@RequestBody ReqActivityMediaInfo reqActivityMediaInfo) {
        mediaService.addActivityMedia(reqActivityMediaInfo);
        return APIResponse.returnSuccess();
    }
    /**
     * 删除活动多媒体
     */
    @RequestMapping(value = "/delActivityMedia", method = RequestMethod.POST)
    public APIResponse delActivityMedia(@RequestBody ReqActivityMediaInfo reqActivityMediaInfo) {
        mediaService.delActivityMedia(reqActivityMediaInfo.getId());
        return APIResponse.returnSuccess();
    }
    /**
     * 查询活动多媒体列表
     */
    @RequestMapping(value = "/queryActivityMediaList", method = RequestMethod.POST)
    public APIResponse queryActivityMediaList(@RequestBody ReqActivityMediaInfo reqActivityMediaInfo) {
        List<RespActivityMedia> tbActivityMultimediaList =  mediaService.queryActivityMediaList(reqActivityMediaInfo.getActivityId());
        return APIResponse.returnSuccess(tbActivityMultimediaList);
    }

    /**
     *
     */
    @RequestMapping(value = "/activityList", method = RequestMethod.POST)
    public APIResponse activityList(@RequestBody ReqActivityMediaInfo reqActivityMediaInfo,HttpServletRequest request) {
        System.out.println(" to do .....");
        Integer uid =getUid(request ,true);
        return APIResponse.returnSuccess(activityOpenService.myActivityList(uid,0,5));
    }
}
